home *** CD-ROM | disk | FTP | other *** search
- .0
- .J 2
- .E
- .G
- .P 65
- .C 88
- .B 12
- .T 8
- GRID2CON
- (c) copyright 1983
-
- Mark A. Herkommer
- PETROSPEC
- 4005 Burning Tree Lane
- Garland, Texas 75042
-
-
-
- I. ABSTRACT
-
- A. Program Title: GRID2CON
-
- B. Programmer: Mark A. Herkommer
-
- C. Date: April 18, 1983 Rev. 2.0
-
- D. Language: Advanced Basic 1.10
-
- E. Machine: IBM PC, Epson MX printer, and
- one disk drive
-
- F. Field Length: Approx. 55K bytes
-
- G. Description: Gridding routine for randomly
- distributed data and line printer
- contour map generator.
-
- H. Input: XYZ or LatLonZ data entered from the
- keyboard or a sequential disk file
-
- I. Output: Files: Gridsave data file
- Printout: Contour map
- .J 1
- .D
- II. INTRODUCTION
-
- GRID2CON is a gridding and contouring program designed to run
- on the IBM PC and an EPSON MX printer. The program's operation
- can be divided into two distinct parts that can be run indepen-
- dently or successionally. The first part reads X, Y, Z or Lat Lon,
- Z data and generates a "gridsave" file that is read by the second.
- The second half reads the gridsave file and generates a line printer
- contour map. Two map projections are currently available for
- converting latitude and longitude into ground meters; Universal
- Transverse Mercator and Polyconic.
-
- GRID2CON has two gridding algorithms available to the user;
- inverse-distance weighted and inverse-distance-squared weighted
- moving averaging. A "skip fator" speed enhancer can be used to
- reduce the time required to grid a set of data. As a third
- "gridding" option, the user can input the coefficents of a polynomial
- surface and have that surface contoured.
-
- Randomly distributed (X, Y, Z or Lat, Lon, Z) data are input into the
- program from a disk file. The output contour map can be viewed on
- the screen, printed on a line printer, or saved in a disk file.
- If the map is printed, the width and height of the characters can be
- varied to improve the resolution. Also, maps that are wider than the
- paper width are automatically printed in strips so that they can be
- pieced together.
-
- III. METHOD OF SOLUTION
-
- A. Gridding
-
- Gridding is the operation that generates a Z-value at regular
- and predictable intervals (X,Y locations) given randomly
- distributed XYZ data points. In version 1.0 of GRID2CON, only
- rectangular gridding is performed.
-
- One may think of the grid as a series of of reqularly spaced
- horizontal and vertical lines at the intersection of which is
- a Z-value calculated. These intersections are called grid
- nodes and 4 of these define the smallest grid unit called a
- grid cell.
-
- When gridding, the distance from the grid node to each of the
- XYZ data points (hereafter called control points), is calcu-
- lated using the user's engineering units. If the calculated
- distance between the control point and grid node is less than
- the "Search Radius", then the inverse-distance is used to weight
- that control point's contribution to the average at that
- grid node. All the control points are tested against the search
- for each of the grid nodes. This type of weighting is used
- because points further away are thought to influence the value
- at the node less. The greater the distance, the less the
- weight. The distance is calculated by:
-
- D^2 = ( X2 - X1 )^2 + ( Y2 - Y1)^2
-
- Where D is the distance between the node and the control point,
- X1 is the CP X-location, X2 is the grid node X-location, Y1 is
- the CP Y-location, and Y2 is the grid node Y-location. The
- Z-value is computed by:
-
- Zsum = Z1/D1 + Z2/D2 + Z3/D3 + ... + Zn/Dn
-
- The sum of the weights is:
-
- Dsum = 1/D1 + 1/D2 + 1/D3 + ... + 1/Dn
-
- and the Z-value at the node is:
-
- Zvalue = Zsum/Dsum
-
- These calculations are performed at each node in the map area.
- The search radius is calculated as 1/2 the diagonal distance
- of the map area, although this can be overridden. Nodes that
- have no control points close enough to pass the search radius
- test are assigned a value of 1E+32 (undefined).
-
- Traditionally when making line printer contour maps, each
- character of the printer is considered a node and a value is
- calculated for each. Thus, a map that figures to be 20"x20"
- has 200 columns (at 10 cpi) and 160 rows (at 8 lpi) and
- would require 32,000 node calculations. For most, the time
- required to calculate a grid of this size would be
- prohibative. It is because of this time consideration that
- a skip factor is used.
-
- B. Trend Surface Coefficents
-
- The highest order polynomial that can be contoured is an
- 8th. In this case, 45 coefficents would be required.
- The number of ceofficents can be determined by:
-
- NCoefficents = (Order+1) * (Order+2)/2
-
- All required coefficents must be entered, although any can have
- the default value of 0. The coefficents correspond to the
- the polynomial thusly:
-
- Z-value = C1 + C2*X + C3*Y + C4*X^2 + C5*X*Y + C6*Y^2 +
- C7*X^3 + C8*X^2*Y + C9*X*Y^2 + C10*Y^3 + ...
-
- Coefficents must be entered in this order for the calculations
- to be performed correctly.
-
- C. Skip Factor
-
- The skip factor is nothing more than the number of columns
- that are skipped between grid nodes on each line (row) of the
- contour map. The gridding time is reduced by a factor of the
- skip factor. In the above example, a skip factor of 30 would
- mean that a total of 1280 nodes would be calculated. Depending
- upon the curvature of the surface being calculated, skip
- factors as large as 1/4 the map width can produce satisfactory
- results. Between the calculated nodes the Z-values are
- linearly interpolated.
-
- The skip factor is not used in the calculations of the
- vertical component of the line printer map. Because of this,
- map resolution remains very high in the Y-direction.
-
- IV. PROGRAM OPTIONS AND RESTRICTIONS
-
- A. Options -- gridding
-
- Three surface generating algortihms are available, as discussed
- above. A sutiable program for deriving the coefficents of a
- trend surface is CURVFIT-3D, available from PETROSPEC.
-
- The scale of the map per inch will determine the number of
- columns and rows in the map area. The default character spacing
- is 10 characters per inch horizontally and 8 lines per inch ver-
- tically. Thus a map 6 inches wide <the default>, will have
- 60 columns and 48 rows. GRID2CON will automatically panelize
- if it cannot plot the map within the width of the panel
- set by the user <80 is the default>. It is worth noting that
- 17 columns are used to draw the margins and axis labels on
- each panel. Compressed and subscript characters are available
- to persons with EPSON MX printers. These options improve the
- resolution of the map. Vertical spacing greater than 10 cpi
- will put the printer input subscript mode.
-
- The Search radius is calculated as 1/2 the map diagonal,
- however, this can be input when the user is queried. If
- a search radius is two small, many nodes will have 'undefined'
- values, shown by a '*' on the map. A large Search radius will
- tend produce a map of moving averages for the whole map area--
- this is sometimes desirable.
-
- B. Options -- contouring
-
- Panel width can be set so the map will fit on the media it
- has been directed to. The map will plot on the screen <SCRN:>
- unless the user specifies otherwise. Other specifications might
- be LPT1: for the line printer, or B:MAP.FIL for a disk file.
- This option has been provided so the user can save her results
- in a file for future reference, or to make multiple copies
- without rerunning the job.
-
- C. Restrictions
-
- Only 1000 data points can be gridded. Points numbering over
- 1000 are ignored.
-
- Grid nodes are saved in the grid-save file of the user's
- specification. If she is using a 320K drive, this would
- permit about 32K nodes to be saved without a disk full error
- (c. 10 bytes/node).
-
- Latitude and longitude input must be positive, in decimal
- degrees, and in the northern half of the western hemisphere.
-
- V. PROGRAM INPUT
-
- Keyboard input should always be in upper case letters. There
- are three styles of prompts used in the program, each asks
- for a particular input data type. They are
-
- "=" asks for numeric input
- ":" asks for an alpha-numeric string
- "?" asks for Y or N (Yes or No)
-
- The default value is shown between <>.
-
- XZY data must be in a sequential file arranged as X Y Z values.
- Latitude/longitude Z values must be in a sequential file
- arranged in that order. No special characters can be present.
- Data may be separated by spaces or commas. There can be no
- header cards, or any other superfluous information in the
- control point file. When plotting a trend surface,
- at least 2 records must be present to define the limits
- of the map area.
-
- VI. PROGRAM OUTPUT
-
- A. Grid-save file
-
- The grid-save file is a sequential file in ASCII format and
- has the following structure:
-
- record 1: title
- record 2: Xmin,Xmax,Ymin,Ymax,Zmin,Zmax,MAPSCALE,ISTATE,CM,
- 0,0,0,0,NROWS,NROWSKIP,NCOLS,NCOLSKIP,ALGORITHM#,
- SEARCHRADIUS,NORDER,CHRHOR,CHRVERT
- record 3-last: Zatthenode,NUMPOINTSusedtoestimateZ
-
- Z-values start in the upper left corner of the map area, and
- move left-to-right then down, and left-to-right again, etc.
- If no points passed the Search radius test, then Z=1E+32
- and NPTS=0. If a trend surface was gridded, then Z=
- the calculated Z-value at the given X Y location. The
- number of points used to estimate Z will always equal 1.
- ISTATE is the map projection and CM is the central merridian.
-
- B. Contour maps
-
- Below is a sample contour map made from synthetic data.
-
-
- PANEL 1 OF 1 synthetic data--ncskip=1--npts=11
-
- ^xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx+
- y 55555 44 333333 22 1 $$ AA BBB CCC DD EEEEy= 5
- y 55555 44 3333333 22 11 $$ AA BBB CCCC DD EEEEy
- y 44 4 333333 2 11 $$ AA BB CCCC CDDD EEEy
- y4444 44 333333 22 11 $ AA BBB CCCC DDD y
- y444444 444444 33333 22 11 $$ AA BB CCCCC DDD y
- y 44444444444 3333 22 11 $$ AA BB CCCC DDDDDy
- y 4444 333 222 11 $$ AA BB CCCC DDy
- y33 333333 2222 11 $$ AAA BBB CCC y
- y333333 333333 222 11 $$ AA BBB CCC y
- y333333333 222 111 $$$ AAA BBB CCC CCCCCCCCy
- y 22222 111 $$$ AAAA BBB CCCCCCCCCCCCCCy
- y 22222222 111 $$$ AAA BBBB CCCCCCCCCCCCCy
- y2222222222222 1 $$$ AAAA BBBB CCCCCCC Cy
- y22222222 11111 $$$ AAAA BBBBB y
- y222222 1111111 $$$$$ AAA BBBBB y
- y 1111111 $$$$ AAA BBBBBBB y
- y 111111 $$$$$ AAA BBBBBBBBBBBBBBy
- y 1111111 $$$$$$ AAA BBBBBBBBBBBBBBy
- y1111111111 $$$$$$$$ AAAA B BBBBBy
- y1111111 $$$$$$$$$$$ AAAA y
- y1111 $$$$$$$$$$$$$$$ AAAA y
- y $$$$$$$$ $$$$$$$ AAAAAAA AAAAy
- y $$$$$$ $$$$$$$$$ AAAAAAAAA AAAAAAAAAAAAAy
- y $$$$$$ $$$$$$$$$ AAAAAAAAAAAAAAAAAAAAAAy
- y $$$$$$$ $$$$$$$$ AAAAAAAAAAAAAAAA y
- y $$$$$$$$ A $$$$$$$ AAAAAAAAAAAAAA y
- y $$$$$$$$ AAAAAAA $$$$$$ AAAAAAAAAAA y
- y $$$$$$$$ AAAAAAAAA AAAAAAA $$$y
- y $$$$$$$ AAAAA AAAAA AA $$$$$$y
- y $$$$$$ AAA AAAA AA $$$$$$$$y
- y$$$$$$$$ AAA AAAA $$$$$$$$$$y
- y$$$$$$$$ AAA AAAA $$$$$$$$$$$y
- y$$$$$$$ AAA AAAAA $$$$$$$$$$$$$$$y
- y$$$$$$$$ AAA AAAAAAA $$$$$$$$$$$$$$$$y
- y$$$$$$$ AAA AAAAAAA $$$$$$$$ $$$y
- y$$$$$$$$$$ AAAA AAAAAAAA $$$$$$ y
- y$$$$$$$$$$$$ AAAAAAAAAAAAAA $$$$$$ 111111y
- y $$$$$$$$$$$$ AAAAAAAAAA $$$$$$ 11111 y
- y $$$$$$$$$$$$ AAAAAA $$$$$$ 1111 y
- y $$$$$$$$$$$$ $$$$$$$ 1111 y
- y $$$$$$$$$$$$ $$$$$$$$$$$ 111 y
- y1 $$$$$$$$$$$ $$$$$$$$$$ 111 y
- y111 $$$$$$$$$$$ $$$$$$$$$$ 11111 y
- y1111 $$$$$$$$$$$ $$$$$$$$$$$ 111111 y
- y 1111 $$$$$$$$$$$$ $$$$$$$$$$$$$ 11111111 y
- y 111 $$$$$$$$$$$$$ $$$$$$$$$$$$$$$ 11111111 y
- y 111 $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ 111111111y
- y 111 $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ 111111 y=-1
- -xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx>
- ! !
- -1 5
-
- Contour interval = .3
- Column skip factor = 1
- Gridded by inverse-distance-squared weighting
-
- *** KEY ***
- 9.000E-01 <= value < 1.200E+00 ="E"
- 1.200E+00 <= value < 1.500E+00 =" "
- 1.500E+00 <= value < 1.800E+00 ="D"
- 1.800E+00 <= value < 2.100E+00 =" "
- 2.100E+00 <= value < 2.400E+00 ="C"
- 2.400E+00 <= value < 2.700E+00 =" "
- 2.700E+00 <= value < 3.000E+00 ="B"
- 3.000E+00 <= value < 3.300E+00 =" "
- 3.300E+00 <= value < 3.600E+00 ="A"
- 3.600E+00 <= value < 3.900E+00 =" "
- 3.900E+00 <= value < 4.200E+00 ="$"
- 4.200E+00 <= value < 4.500E+00 =" "
- 4.500E+00 <= value < 4.800E+00 ="1"
- 4.800E+00 <= value < 5.100E+00 =" "
- 5.100E+00 <= value < 5.400E+00 ="2"
- 5.400E+00 <= value < 5.700E+00 =" "
- 5.700E+00 <= value < 6.000E+00 ="3"
- 6.000E+00 <= value < 6.300E+00 =" "
- 6.300E+00 <= value < 6.600E+00 ="4"
- 6.600E+00 <= value < 6.900E+00 =" "
- 6.900E+00 <= value < 7.200E+00 ="5"
- undefined ="*"
- .D
- VII. LICENSE
-
- You may:
-
- A. use this program on a single machine;
-
- B. copy this program into any machine readable or printed
- form for backup in support of your use on a single
- machine;
-
- C. copy this documentation for personal use or use within
- your organization;
-
- D. terminate this license by destroying all machine
- readable and printed copies, including all modifica-
- tions and portions of this program contained or merged
- into other programs;
-
- E. transfer this license to another party only if the
- other party accepts the terms and conditions of this
- license. If you transfer this program, then you must
- at the same time either transfer all copies whether
- in machine readable or printed form to the same party
- or destroy all copies not transferred, including all
- modifications and portions of the program contained
- or merged into other programs.
-
- You may not:
-
- A. transfer this license except as expressly provided
- for in this license.
-
- Term:
-
- This license is in effect until terminated. If you transfer
- posession of any copy, modification or merged portion of this
- program to another party, your license is automatically
- terminated.
- fafaifae+n un ohE,s hhatfaenalue < 5.100E+00 =" "
- 5.100E+00 <= value < 5.400E+00 ="2"
- 5.400E+00 <= value < 5.700E+00 =" "
- 5.700E+00 <= value < 6